package com.lening.gateway.config;

import com.lening.gateway.filter.ResponseBodyFilter;

import org.springframework.cloud.gateway.filter.factory.rewrite.ModifyResponseBodyGatewayFilterFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author 杨军
 * @datetime 2024/5/16 19:26
 * @description 类对象
 */
@Configuration
public class GlobalFilterConfiguration {

    /**
     * 响应体过滤器
     *
     * @return
     */
    @Bean
    public com.lening.gateway.handler.BodyRewriteFunction bodyRewriteFunction() {
        return new com.lening.gateway.handler.BodyRewriteFunction();
    }

    @Bean
    public ResponseBodyFilter responseBodyFilter(ModifyResponseBodyGatewayFilterFactory filterFactory) {
        return new ResponseBodyFilter(filterFactory, bodyRewriteFunction());
    }

}
